﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;

namespace Agresso.Interface.Layer.Domain
{
    public class CommissionManagersLegalEntity
    {
        public long cmle_id = 0;

        public string profit_centre_softmar = "";
        public string profit_centre_agresso = "";
        public string profit_centre_agresso_dim_val = "";

        public string vessel_softmar = "";
        public string vessel_agresso = "";
        public string vessel_agresso_dim_val = "";

        public string commercial_manager = "";
        public string commercial_manager_dim_val = "";

        public DateTime created_date = new DateTime(1900, 1, 1);
        public DateTime modified_date = new DateTime(1900, 1, 1);

        public CommissionManagersLegalEntity() { }
        public CommissionManagersLegalEntity(SqlDataReader rd)
        {
            cmle_id = Convert.ToInt32(rd["cmle_id"]);
            profit_centre_softmar = rd["profit_centre_softmar"] is DBNull ? profit_centre_softmar : rd["profit_centre_softmar"].ToString();
            profit_centre_agresso = rd["profit_centre_agresso"] is DBNull ? profit_centre_agresso : rd["profit_centre_agresso"].ToString();
            profit_centre_agresso_dim_val = rd["profit_centre_agresso_dim_val"] is DBNull ? profit_centre_agresso_dim_val : rd["profit_centre_agresso_dim_val"].ToString();

            vessel_softmar = rd["vessel_softmar"] is DBNull ? vessel_softmar : rd["vessel_softmar"].ToString();
            vessel_agresso = rd["vessel_agresso"] is DBNull ? vessel_agresso : rd["vessel_agresso"].ToString();
            vessel_agresso_dim_val = rd["vessel_agresso_dim_val"] is DBNull ? vessel_agresso_dim_val : rd["vessel_agresso_dim_val"].ToString();

            commercial_manager = rd["commercial_manager"] is DBNull ? commercial_manager : rd["commercial_manager"].ToString();
            commercial_manager_dim_val = rd["commercial_manager_dim_val"] is DBNull ? commercial_manager_dim_val : rd["commercial_manager_dim_val"].ToString();

            created_date = rd["created_date"] is DBNull ? created_date : Convert.ToDateTime(rd["created_date"]);
            modified_date = rd["modified_date"] is DBNull ? modified_date : Convert.ToDateTime(rd["modified_date"]);
        }

        public bool IsValid()
        {
            return commercial_manager_dim_val != string.Empty;
        }
    }
}
